<template>
  <div class="view_page " style="height: calc(100% - 20px)">
    <el-card class="box-card" style="height: 100%;">
      <!--卡片头部-->
      <div slot="header" class="clearfix">
        <!--左侧-->
        <div class="left">
          <div class="back-page">
            <div class="add-back" @click="back">
              <i class="fa fa-arrow-left" aria-hidden="true"></i>
              <span>
                {{groupName}}-测点列表
              </span>
            </div>
          </div>
        </div>
      </div>
      <!-- 卡片内容 -->
      <div>
        <el-table :data="datalist" style="width: 100%" ref="myTable">
          <el-table-column v-for="(item,ind) in tableList" :key="ind"
                           :label="item.label"
                           :prop="item.key" :align="item.align"
                           :min-width="item.minWidth">
            <template slot-scope="scope">
              <div v-if="!item.isCustom" class="text-ellipsis-2">
                {{scope.row[item.key]||item.defaultText }}
              </div>
              <div class="text-ellipsis-2"
                   v-if="item.isCustom&&item.key!='ind'">
                {{scope.row[item.key]||item.defaultText }}
              </div>
              <div class="text-ellipsis-2"
                   v-if="item.isCustom&&item.key=='ind'">
                {{ scope.$index +1}}
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-card>
  </div>
</template>

<script>
  import {Message} from "element-ui";
  import pagination from "@/components/common/pagination/pagination";

  export default {
    name: 'monitorGroup',
    components: {
      pagination,
    },
    data() {
      return {
        token: "",
        userInfo: JSON.parse(localStorage.getItem("loginPersonnelInformation")),
        groupName: '',
        // TODO.全局
        tableList: [
          {
            key: 'ind',
            label: '序号',
            align: 'center',
            minWidth: '100',
            defaultText: '--',
            isCustom: true,
          },
          {
            key: 'name',
            label: '测点名称',
            align: 'center',
            minWidth: '120',
            defaultText: '--',
            isCustom: false,
          },
          {
            key: 'monitor_num',
            label: '测点编号',
            align: 'center',
            minWidth: '120',
            defaultText: '--',
            isCustom: false,
          },
        ],
        datalist: [],
        pageNum: 1,
        page: 1,
        size: 10,
        total: 0,
        all_datalist: [],
      };
    },
    created() {
      let data = this.$route.query.data;
      if (data.name) {
        this.groupName = data.name || '';
      }
      if (data.data) {
        this.datalist = JSON.parse(data.data);
      }
    },
    methods: {
      //分页
      searchPagination(page) {
        this.page = page
        localStorage.setItem('page', page)
        if (this.activeTabName == 'all' && this.activeSubTabName
          == 'realtime_status') {
          this.datalist = []
          this.getListPage()
        }
      },
      back() {
        this.$router.back()
      },
    }
  };
</script>

<style>
</style>
